package com.hxexp.weixin.test;

import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import com.hxexp.weixin.common.string.StringHelper;
import com.hxexp.weixin.test.runner.JUnit4WithLogClassRunner;

@RunWith(JUnit4WithLogClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class StringHelperTester {

    @Test
    public void testCase01() {
        String xml = "<xml>\n" + "<ToUserName><![CDATA[gh_ac216ed6e766]]></ToUserName>\n"
                + "<FromUserName><![CDATA[o5GuMs3VA_8xB6VCNKaTdFQHVQ_U]]></FromUserName>\n" + "<CreateTime>1428562454</CreateTime> \n"
                + "<MsgType><![CDATA[event]]></MsgType>\n" + "<Event><![CDATA[CLICK]]></Event>\n" + "<EventKey><![CDATA[h]]></EventKey>\n"
                + "</xml>  ";
        String returnValue = StringHelper.replaceXMLEscapeChar(xml);
        System.out.println(returnValue);
    }

    @Test
    public void testCase02() {
        String identificationNumber = "510124199009228405";
        String expected = "510124****8405";
        String returnValue = StringHelper.hiddenIDNumber(identificationNumber);
        System.out.println(returnValue);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase03() {
        String phoneNo = "13688880098";
        String expected = "136****0098";
        String returnValue = StringHelper.hiddenPhoneNumber(phoneNo);
        System.out.println(returnValue);
        Assert.assertEquals(expected, returnValue);
    }
}
